import {Alert, Button, Text, View} from 'react-native';
import React, {Component} from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import UseStorage from './useStorage';
export default class AsyncStorageCom extends Component {
  storeData = async value => {
    try {
      await AsyncStorage.setItem('mytest', value);
    } catch (e) {
      console.log(e);
    }
  };
  getStoreData = async () => {
    try {
      Alert.alert(await AsyncStorage.getItem('mytest'));
    } catch (e) {
      console.log(e);
    }
  };
  render() {
    console.log(UseStorage);
    return (
      <View>
        <Button onPress={() => this.storeData('123')} title="存储" />
        <Button onPress={this.getStoreData} title="获取" />
        <Button title="清空" onPress={UseStorage.clear} />
      </View>
    );
  }
}
